package com.zbkj.common.request.project;

import com.zbkj.common.enums.ProjectParamGuoEnum;
import com.zbkj.common.exception.CommonException;
import com.zbkj.common.model.project.ProjectParamGuo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.beans.BeanUtils;

import java.util.Objects;

/**
 * @Auther:
 * @Date: 2024/10/7 17:54
 * @Description:
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "ProjectParamGuoRequest对象", description = "项目国标调整因子保存请求对象")
public class ProjectParamGuoRequest {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("规模计数时机-选择项")
    private Integer paramItem1;

    @ApiModelProperty("应用类型-选择项")
    private Integer paramItem2;

    @ApiModelProperty("质量特性-分布式处理-选择项")
    private Integer paramItem3;

    @ApiModelProperty("质量特性-性能-选择项")
    private Integer paramItem4;

    @ApiModelProperty("质量特性-可靠性-选择项")
    private Integer paramItem5;

    @ApiModelProperty("质量特性-多重站点-选择项")
    private Integer paramItem6;

    @ApiModelProperty("完整性级别-选择项")
    private Integer paramItem7;

    @ApiModelProperty("开发语言-选择项")
    private Integer paramItem8;

    @ApiModelProperty("开发团队背景-选择项")
    private Integer paramItem9;

    /**
     * 国标项目类型参数因子检查和pojo类组装
     * @param paramGuoRequest
     */
    public static ProjectParamGuo paramGuoCheckAndToPojo(ProjectParamGuoRequest paramGuoRequest) {
        if(Objects.isNull(paramGuoRequest)) {
            throw new CommonException("请填写调整因子");
        }
        ProjectParamGuo paramGuo = new ProjectParamGuo();
        BeanUtils.copyProperties(paramGuoRequest,paramGuo);
        paramGuo.setParamVal1(ProjectParamGuoEnum.findValAndCheck(paramGuo.getParamItem1(),1));
        paramGuo.setParamVal2(ProjectParamGuoEnum.findValAndCheck(paramGuo.getParamItem2(),2));
        paramGuo.setParamVal3(ProjectParamGuoEnum.findValAndCheck(paramGuo.getParamItem3(),3));
        paramGuo.setParamVal4(ProjectParamGuoEnum.findValAndCheck(paramGuo.getParamItem4(),4));
        paramGuo.setParamVal5(ProjectParamGuoEnum.findValAndCheck(paramGuo.getParamItem5(),5));
        paramGuo.setParamVal6(ProjectParamGuoEnum.findValAndCheck(paramGuo.getParamItem6(),6));
        paramGuo.setParamVal7(ProjectParamGuoEnum.findValAndCheck(paramGuo.getParamItem7(),7));
        paramGuo.setParamVal8(ProjectParamGuoEnum.findValAndCheck(paramGuo.getParamItem8(),8));
        paramGuo.setParamVal9(ProjectParamGuoEnum.findValAndCheck(paramGuo.getParamItem9(),9));
        paramGuo.setPtype(0);
        return paramGuo;
    }
}
